<template>
	<view class="content">
		<view class="searchBox">
			<view class="search">
				<input type="text" v-model="name" class="inp" placeholder="输入快递名称搜索">
				<view class="btn">
					<image src="../../static/image/search.png" @click="searchBtn()" class="icon" mode=""></image>
				</view>
			</view>
		</view>
		<view style="height: 600rpx;" v-if="KDcompany.length==0">
			<u-empty text="暂无消息" mode="message"></u-empty>
		</view>
		<view class="item" v-for="(item,index) in KDcompany" v-else>
			<image :src="imgUrl+item.icon" class="icon" mode=""></image>
			<view class="right">
				<view class="name">
					{{item.name}}
				</view>
				<view style="display: flex;flex-wrap: nowrap;">
					<view class="tag" style="margin-right: 10rpx;" v-for="i in item.tags">
						{{i}}
					</view>
				</view>
				
			</view>
		</view>
	</view>
</template>

<script>
	import {expressList,getSettingInfo} from '../../common/api.js'
	import request from '../../common/common.js'
	export default {
		data() {
			return {
				imgUrl:request.imgUrl,
				list:[],
				KDcompany:[],
				item:{},
				name:''
			}
		},
		onLoad(e) {
			this.getList()
		},
		methods: {
			getList(type){
				getSettingInfo('KDcompany',{}).then(res=>{
					if(res.code==10000){
						this.KDcompany=JSON.parse(res.data.KDcompany)
						this.list=JSON.parse(res.data.KDcompany)
					}
				})
				// expressList({
				// 	name:this.name
				// }).then(res=>{
				// 	if(res.code==10000){
				// 		this.list = res.data
				// 		this.list.forEach((item,index)=>{
				// 			if(item.type=='SF'){
				// 				item.icon='../../static/image/sf.png'
				// 			}else if(item.type=='DOP'){
				// 				item.icon='../../static/image/db.png'
				// 			}else if(item.type=='YTO'){
				// 				item.icon='../../static/image/yt.png'
				// 			}else if(item.type=='JD'){
				// 				item.icon='../../static/image/jd.png'
				// 			}else if(item.type=='JT'){
				// 				item.icon='../../static/image/jt.png'
				// 			}else if(item.type=='STO-INT'){
				// 				item.icon='../../static/image/st.png'
				// 			}else if(item.type=='YUND'){
				// 				item.icon='../../static/image/yd.png'
				// 			}else if(item.type=='ZTO'){
				// 				item.icon='../../static/image/zt.png'
				// 			}else if(item.type=='CNSD'){
				// 				item.icon='../../static/image/cn.png'
				// 			}else if(item.type=='BEST'){
				// 				item.icon='../../static/image/bs.png'
				// 			}else if(item.type=='KY'){
				// 				item.icon='../../static/image/ky.png'
				// 			}else if(item.type=='EMS'){
				// 				item.icon='../../static/image/ems.png'
				// 			}
				// 		})
				// 	}
				// })
			},
			searchBtn(){
				console.log(this.selectArrDataFn(this.name))
				this.KDcompany=this.selectArrDataFn(this.name)
			},
			selectArrDataFn(value) {
			    if (!value.trim()) return this.list;
			    return this.list.filter(item => {
			        return item.name.indexOf(value) !== -1 
			    });
			}
		}
	}
</script>
<style>
	page{
		background: #EDEFF2;
	}
</style>
<style scoped lang="scss">
.content{
	width: 750rpx;
	padding: 32rpx;
	box-sizing: border-box;
	.searchBox{
		width: 100%;
		padding: 24rpx;
		box-sizing: border-box;
		.search{
			width: 100%;
			height: 80rpx;
			background: #fff;
			border-radius: 50rpx;
			padding:0 24rpx;
			box-sizing: border-box;
			display: flex;
			flex-wrap: nowrap;
			align-items: center;
			.inp{
				width: calc(100% - 84rpx - 24rpx);
				height: 100%;
				font-size: 24rpx;
			}
			.btn{
				width: 84rpx;
				height: 52rpx;
				background: #1AA261;
				border-radius: 50rpx;
				margin-left: 24rpx;
				display: flex;
				justify-content: center;
				align-items: center;
				.icon{
					width: 24rpx;
					height: 24rpx;
				}
			}
		}
	}
	.item{
		width: 100%;
		height: 130rpx;
		background: #fff;
		border-radius: 20rpx;
		margin-bottom: 32rpx;
		padding: 33rpx 41rpx;
		box-sizing: border-box;
		display: flex;
		flex-wrap: nowrap;
		align-items: center;
		.icon{
			width: 64rpx;
			height: 64rpx;
			border-radius: 50%;
		}
		.right{
			margin-left: 19rpx;
			.name{
				font-family: PingFangSC, PingFang SC;
				font-weight: 500;
				font-size: 28rpx;
				color: #333333;
				line-height: 28rpx;
				text-align: left;
				font-style: normal;
			}
			.tag{
				margin-top: 12rpx;
				// width: 150rpx;
				// height: 32rpx;
				font-family: PingFangSC, PingFang SC;
				font-weight: 400;
				font-size: 20rpx;
				color: #1AA261;
				line-height: 32rpx;
				text-align: center;
				font-style: normal;
				border: 1rpx solid #1AA261;
				border-radius: 5rpx;
				padding: 3rpx 10rpx;
				box-sizing: border-box;
			}
		}
	}
}
</style>
